package org.wyf.EveryPoint.common.configure;

import com.baomidou.mybatisplus.annotation.DbType;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.wyf.EveryPoint.common.interceptor.DataPermissionInterceptor;
import org.wyf.EveryPoint.common.interceptor.DesensitizationInterceptor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author MrBird
 */
@Configuration
@MapperScan("org.wyf.EveryPoint.*.mapper")
public class MybatisPlusConfigure {
    /**
     * 注册数据权限
     */
    @Bean
    @Order(0)
    public DataPermissionInterceptor dataPermissionInterceptor() {
        return new DataPermissionInterceptor();
    }

    /**
     * 数据脱敏
     */
    @Bean
    @Order(-1)
    public DesensitizationInterceptor desensitizationInterceptor() {
        return new DesensitizationInterceptor();
    }

    /**
     * 注册分页插件  最新版
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
